define(["../common"], function() {
	
	var $form = $("#form");
	var addDoPath = g_shopDomain + "/storeMember/addDo/json";
	var loadStoreMemberPath = g_shopDomain + "/storeMember/list";
	
	$("[id^='submitBt_']").click(function() {
		$form.trigger('validate');
	});
	
	loadjs(["validator"],function() {
		$form.validator({
			fields: {
				userName: "required"
			}
		});
	});
	
	// 表单验证通过后的事件
	$form.on('valid.form', function(e, form){
		if (!$(form).showMsg("正在添加...", 'load', true)) return;
		$.post(addDoPath, $(form).serialize(), function(data){
			if (data.status !== 0) {
				$(form).showMsg(data.message, 'error');
				return;
				
			} 
			$(form).showMsg("添加成功！...", 'pass');
			setTimeout(function() {
				location.href = loadStoreMemberPath;
			}, 1500);
		});
	});
	
});